<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!-- 事件冒泡就是一级一级往父控件传递 -->
    <script src="../jQuery/js/jquery-1.12.4.min.js"></script>
    <script>
        $(function(){
        $('#btn1').click(function(){
            //点击按钮，会冒泡传递到div触发事件
            alert('按钮被点了'); 
            // 添加return false，就不冒泡
            return false;
        })
        $('div').click(function(){
            alert('div触发了');
        })
        $('#ul1').delegate('li','click',function(){
            $(this).css({color:'red'})
        })
    })
    </script>
</head>
<body>
    <div>
        <p id='p1'>hha</p>
        <input type="button" value="按钮" id='btn1'>
    </div>
    <ul id='ul1'>
        <li>1</li>
        <li>2</li>
        <li>3</li>
    </ul>
</body>
</html>